package org.wwx.loadbalancing;

import org.wwx.register.model.ServiceInstance;

import java.util.List;
import java.util.Random;

/**
 * @date 2025/6/6
 * @author王闻薪
 */
public class LoadBalancing {
    private static final Random random = new Random();

    public static ServiceInstance random(List<ServiceInstance> instances) {
        if (instances == null || instances.isEmpty()) {
            throw new RuntimeException("No available service instances");
        }
        return instances.get(random.nextInt(instances.size()));
    }
}
